<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The Swoole\Http\Client class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.swoole-exception.html">« Swoole\Exception</a></li>
      <li style="float: right;"><a href="swoole-http-client.addfile.html">Swoole\Http\Client::addFile »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.swoole.html">Swoole</a></li>
    <li>The Swoole\Http\Client class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.swoole-http-client" class="reference">

 <h1 class="title">The Swoole\Http\Client class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL swoole &gt;= 1.9.0)</p>


  <div class="section" id="swoole-http-client.intro">
   <h2 class="title">简介</h2>
   <p class="para">

   </p>
  </div>


  <div class="section" id="swoole-http-client.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">Swoole\Http\Client</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.swoole-http-client.html#swoole-http-client.props.errcode">$<var class="varname">errCode</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.swoole-http-client.html#swoole-http-client.props.sock">$<var class="varname">sock</var></a></var>;</div>


    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.addfile.html" class="methodname">addFile</a></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$type</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$offset</code><span class="initializer"> = ?</span></span><br>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.close.html" class="methodname">close</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.destruct.html" class="methodname">__destruct</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.download.html" class="methodname">download</a></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$file</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$offset</code><span class="initializer"> = ?</span></span><br>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.execute.html" class="methodname">execute</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$callback</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.get.html" class="methodname">get</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.isconnected.html" class="methodname">isConnected</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.on.html" class="methodname">on</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$event_name</code></span>, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.post.html" class="methodname">post</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.push.html" class="methodname">push</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$opcode</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$finish</code><span class="initializer"> = ?</span></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.set.html" class="methodname">set</a></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$settings</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.setcookies.html" class="methodname">setCookies</a></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$cookies</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.setdata.html" class="methodname">setData</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>): <span class="type"><span class="type ReturnType">ReturnType</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.setheaders.html" class="methodname">setHeaders</a></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$headers</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.setmethod.html" class="methodname">setMethod</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$method</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-http-client.upgrade.html" class="methodname">upgrade</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$callback</code></span>): <span class="type"><span class="type void">void</span></span></div>

   }</div>


  </div>

  

  <div class="section" id="swoole-http-client.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="swoole-http-client.props.errcode"><var class="varname">errCode</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="swoole-http-client.props.sock"><var class="varname">sock</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
   </dl>

  </div>



 </div>

 
























































































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="swoole-http-client.addfile.html">Swoole\Http\Client::addFile</a> — Add a file to the post form.</li><li><a href="swoole-http-client.close.html">Swoole\Http\Client::close</a> — Close the http connection.</li><li><a href="swoole-http-client.construct.html">Swoole\Http\Client::__construct</a> — Construct the async HTTP client.</li><li><a href="swoole-http-client.destruct.html">Swoole\Http\Client::__destruct</a> — Destruct the HTTP client.</li><li><a href="swoole-http-client.download.html">Swoole\Http\Client::download</a> — Download a file from the remote server.</li><li><a href="swoole-http-client.execute.html">Swoole\Http\Client::execute</a> — Send the HTTP request after setting the parameters.</li><li><a href="swoole-http-client.get.html">Swoole\Http\Client::get</a> — Send GET http request to the remote server.</li><li><a href="swoole-http-client.isconnected.html">Swoole\Http\Client::isConnected</a> — Check if the HTTP connection is connected.</li><li><a href="swoole-http-client.on.html">Swoole\Http\Client::on</a> — Register callback function by event name.</li><li><a href="swoole-http-client.post.html">Swoole\Http\Client::post</a> — Send POST http request to the remote server.</li><li><a href="swoole-http-client.push.html">Swoole\Http\Client::push</a> — Push data to websocket client.</li><li><a href="swoole-http-client.set.html">Swoole\Http\Client::set</a> — Update the HTTP client paramters.</li><li><a href="swoole-http-client.setcookies.html">Swoole\Http\Client::setCookies</a> — Set the http request cookies.</li><li><a href="swoole-http-client.setdata.html">Swoole\Http\Client::setData</a> — Set the HTTP request body data.</li><li><a href="swoole-http-client.setheaders.html">Swoole\Http\Client::setHeaders</a> — Set the HTTP request headers.</li><li><a href="swoole-http-client.setmethod.html">Swoole\Http\Client::setMethod</a> — Set the HTTP request method.</li><li><a href="swoole-http-client.upgrade.html">Swoole\Http\Client::upgrade</a> — Upgrade to websocket protocol.</li></ul>
</div>
</div></div></body></html>